package com.ruoyi.web.controller.biz.hugong.openapi;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.biz.EmployeeVo;
import com.ruoyi.system.domain.dto.EmployeeAndReleationDto;
import com.ruoyi.system.domain.vo.EmployQueryVo;
import com.ruoyi.system.domain.vo.RoleRegisterVo;
import com.ruoyi.system.service.IEmployeeService;
import com.ruoyi.system.wx.login.domain.WxLoginVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName EmployeeOpenApi
 * @Description
 * @Author sizegang
 * @Date2024/11/30 13:06
 **/
@RestController
@RequestMapping("/openapi/employee")
public class EmployeeOpenApi extends BaseController {
    @Autowired
    private IEmployeeService employeeService;

    @ApiOperation("员工一键登录")
    @Log(title = "【员工一键登录】", businessType = BusinessType.DELETE)
    @PostMapping("employeeLogin")
    public AjaxResult employeeLogin(@RequestBody WxLoginVo wxLoginVo) {
        return success(employeeService.employeeLogin(wxLoginVo));
    }


    /**
     * Employee register ajax result.
     *
     * @param wxLoginVo the wx login vo
     * @return the ajax result
     */
    @ApiOperation("员工注册")
    @Log(title = "【员工注册】", businessType = BusinessType.DELETE)
    @PostMapping("employeeRegister")
    public AjaxResult employeeRegister(@RequestBody WxLoginVo wxLoginVo) {
        return success(employeeService.employeeRegister(wxLoginVo));
    }


    @ApiOperation("真正员工的注册")
    @PostMapping("doRegister")
    public AjaxResult doRegister(@RequestBody RoleRegisterVo roleRegisterVo) {
        try {
            return success(employeeService.doRegister(roleRegisterVo));
        } catch (Exception exception) {
            return error(exception.getMessage());
        }
    }


    @ApiOperation("工作信息提交接口")
    @PostMapping("workInfoSubmit")
    public AjaxResult workInfoSubmit(@RequestBody RoleRegisterVo roleRegisterVo) {
        try {
            employeeService.workInfoSubmit(roleRegisterVo);
        } catch (Exception exception) {
            return error(exception.getMessage());
        }
        return success("工作信息提交成功");
    }


    @ApiOperation("获取护工列表[客户端接口]")
    @PostMapping("getEmployeeListByQueryType")
    public AjaxResult getEmployeeListByQueryType(@RequestBody EmployQueryVo employQueryVo) {
        try {
            List<EmployeeAndReleationDto> employeList = employeeService.getEmployeeListByQueryType(employQueryVo);
            return success(employeList);
        } catch (Exception exception) {
            return error(exception.getMessage());
        }
    }


    @ApiOperation("修改护工信息")
    @PostMapping("updateEmployeeInfo")
    public AjaxResult updateEmployeeInfo(@RequestBody EmployeeVo employeeVo) {
        try {
            return success(employeeService.updateEmployeeInfo(employeeVo));
        } catch (Exception exception) {
            return error(exception.getMessage());
        }
    }

    @ApiOperation("修改护工信息")
    @PostMapping("updateWorkInfo")
    public AjaxResult updateWorkInfo(@RequestBody RoleRegisterVo roleRegisterVo) {
        try {
            return success(employeeService.updateWorkInfo(roleRegisterVo));
        } catch (Exception exception) {
            return error(exception.getMessage());
        }
    }


    @ApiOperation("查询护工详情")
    @PostMapping("queryEmployeeInfo")
    public AjaxResult queryEmployeeInfo(@RequestBody EmployeeVo employeeVo) {
        try {
            return success(employeeService.queryEmployeeInfo(employeeVo));
        } catch (Exception exception) {
            return error(exception.getMessage());
        }
    }

}
